/************************************************************
   Copyright 2008 Abhinav Pobbati

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*************************************************************/

#include "HkPrerequisites.h"

#include "Havok4Xna/Common/Base/Math/HkMatrix3.h"
#include "Havok4Xna/Common/Base/Math/HkVector4.h"
#include "Havok4Xna/Common/Base/Math/HkTransform.h"
#include "Havok4Xna/Common/Base/Math/HkQsTransform.h"
#include "Havok4Xna/Common/Base/Math/HkQuaternion.h"

namespace Havok4Xna {
	HkMatrix3::HkMatrix3(HkMatrix3 ^mat) {
		_setThis(new hkMatrix3(mat->_ref()), true);
	}
	HkMatrix3::HkMatrix3() {
		_setThis(new hkMatrix3(), true);
	}
	float HkMatrix3::Get(int row, int col) {
		return _ref()(row, col);
	}
	void HkMatrix3::Set(int row, int col, float value) {
		_ref()(row, col) = value;
	}
	void HkMatrix3::SetRows(HkVector4 ^v0, HkVector4 ^v1, HkVector4 ^v2) {
		_this()->setRows(v0->_ref(), v1->_ref(), v2->_ref());
	}
	void HkMatrix3::SetCols(HkVector4 ^v0, HkVector4 ^v1, HkVector4 ^v2) {
		_this()->setCols(v0->_ref(), v1->_ref(), v2->_ref());
	}
	void HkMatrix3::SetZero() {
		_this()->setZero();
	}
	void HkMatrix3::SetDiagonal(float m00, float m11, float m22) {
		_this()->setDiagonal(m00, m11, m22);
	}
	void HkMatrix3::SetIdentity() {
		_this()->setIdentity();
	}
	bool HkMatrix3::IsApproximatelyEqual(HkMatrix3 ^m, float epsilon) {
		return _this()->isApproximatelyEqual(m->_ref(), epsilon);
	}
	void HkMatrix3::SetCrossSkewSymmetric(HkVector4 ^v) {
		_this()->setCrossSkewSymmetric(v->_ref());
	}
	HkResult HkMatrix3::Invert(float epsilon) {
		return (HkResult) _this()->invert(epsilon);
	}
	void HkMatrix3::InvertSymmetric() {
		_this()->invertSymmetric();
	}
	void HkMatrix3::Transpose() {
		_this()->transpose();
	}
	void HkMatrix3::SetTranspose(HkMatrix3 ^mat) {
		_this()->setTranspose(mat->_ref());
	}
	void HkMatrix3::SetMul(HkMatrix3 ^a, HkMatrix3 ^b) {
		_this()->setMul(a->_ref(), b->_ref());
	}
	void HkMatrix3::SetMulInverse(HkMatrix3 ^a, HkRotation ^r) {
		_this()->setMulInverse(a->_ref(), r->_ref());
	}
	void HkMatrix3::SetMul(float scale, HkMatrix3 ^m) {
		_this()->setMul(scale, m->_ref());
	}
	void HkMatrix3::AddMul(float scale, HkMatrix3 ^m) {
		_this()->addMul(scale, m->_ref());
	}
	void HkMatrix3::ChangeBasis(HkRotation ^r) {
		_this()->changeBasis(r->_ref());
	}
	void HkMatrix3::Add(HkMatrix3 ^m) {
		_this()->add(m->_ref());
	}
	void HkMatrix3::Sub(HkMatrix3 ^m) {
		_this()->sub(m->_ref());
	}
	void HkMatrix3::Mul(HkMatrix3 ^m) {
		_this()->mul(m->_ref());
	}
	void HkMatrix3::Mul(float scale) {
		_this()->mul(scale);
	}
	bool HkMatrix3::IsOk() {
		return _this()->isOk();
	}

	HkRotation::HkRotation() {
		_setThis(new hkRotation(), true);
	}
	void HkRotation::Set(HkQuaternion ^q) {
		_ref().set(q->_ref());
	}
	void HkRotation::SetAxisAngle(HkVector4 ^v, float angle) {
		_ref().setAxisAngle(v->_ref(), angle);
	}
	bool HkRotation::IsOrthonormal(float epsilon) {
		return _ref().isOrthonormal(epsilon);
	}
	void HkRotation::Renormalize() {
		_ref().renormalize();
	}
}
